package org.smartercontext.remotedeployable;

import java.util.ArrayList;
import java.util.List;

import org.smartercontext.contextmger.json.writer.IJSONWriter;
import org.smartercontext.contextmger.json.writer.JSONWriter;

public class UserPreferences {

	private List<String>productsSeen;
	private List<String>wishlistCreated;
	private List<String>productsRanked;
	private String username;
	
	public UserPreferences(String username){
		productsSeen = new ArrayList<>();
		wishlistCreated = new ArrayList<>();
		productsRanked = new ArrayList<>();
		this.username = username;
	}
	
	public void addProductSeen(String product){
		
		if(!productsSeen.contains(product)){
			productsSeen.add(product);
		}
	}
	
	public void addtoWishlist(String product){
		
		if(!wishlistCreated.contains(product)){
			wishlistCreated.add(product);
		}
	}
	
	public void addProductRanked(String product){
		
		if(productsRanked.contains(product)){
			productsRanked.add(product);
		}
	}

	public List<String> getProductsSeen() {
		return productsSeen;
	}

	
	public List<String> getWishlistCreated() {
		return wishlistCreated;
	}

	public List<String> getProductsRanked() {
		return productsRanked;
	}

	public String getUsername() {
		return username;
	}
	
	public String getInfoAtJSONformat(){
				
		IJSONWriter jsonWiter = new JSONWriter();
		String json = jsonWiter.writeBuyerPreferences(wishlistCreated, productsSeen, productsRanked, username);
		
		return json;
	}
	
	public void chargeTestData(){
		
		//Products seen
		chargeTestDataProductsSeen();
		
		//Wishlist
		chargeTestDataWishList();
		
		//Products ranked
		chargeTestDataProductsRanked();
		
	}
	
	private void chargeTestDataProductsRanked(){
		String product1 = "5#Product R1#0294234934#92382131283123#8237123";
		String product2 = "3#Product R2#00034456423656#93298348234#2143434";
		String product3 = "3#Product R3#0103445655656#98898348234#2333434";
		String product4 = "2#Product R4#003203445655656#98898348234#2313434";
		String product5 = "4#Product R6#34145655656#98898348234#2333434";
		String product6 = "1#Product R7#01003445655656#98898348234#23431233434";
		String product7 = "2#Product R8#00034415655656#98898348234#23434312334";
		String product8 = "2#Product R9#00013445651235656#98898348234123#312343434";
		
		productsRanked.add(product1);
		productsRanked.add(product2);
		productsRanked.add(product3);
		productsRanked.add(product4);
		productsRanked.add(product5);
		productsRanked.add(product6);
		productsRanked.add(product7);
		productsRanked.add(product8);
		
		
	}
	
	private void chargeTestDataWishList(){
		
		String product1 = "Product WS1#0003445655656#98898348234#2343434";
		String product2 = "Product WS2#00034456423656#93298348234#2143434";
		String product3 = "Product WS3#0103445655656#98898348234#2333434";
		String product4 = "Product WS4#003203445655656#98898348234#2313434";
		String product5 = "Product WS5#00034145655656#98898348234#2333434";
		String product6 = "Product WS6#01003445655656#98898348234#23431233434";
		
		wishlistCreated.add(product1);
		wishlistCreated.add(product2);
		wishlistCreated.add(product3);
		wishlistCreated.add(product4);
		wishlistCreated.add(product5);
		wishlistCreated.add(product6);
		
	}
	
	private void chargeTestDataProductsSeen(){
		
		String product1 = "Hellmans Tomato Sauce#0003445655656#98898348234#2343434";
		String product2 = "Cocacola pet 2Lt#00034456423656#93298348234#2143434";
		String product3 = "Ritz cookies x 12 units#0103445655656#98898348234#2333434";
		String product4 = "TV Samsung 42P#003203445655656#98898348234#2313434";
		String product5 = "Samsung Galaxy S4#00034145655656#98898348234#2333434";
		String product6 = "Nutella 300Gr#01003445655656#98898348234#23431233434";
		String product7 = "Whirpool washing machine#00034415655656#98898348234#23434312334";
		String product8 = "Whirpool microwave 2000Watts#00013445651235656#98898348234123#312343434";
		String product9 = "Panasonic Fan 15P#001034456556516545236#91238898348234#2343434";
		String product10 = "Saint Lucas Eggs x 15 un#001034145655664556#98898312348234#2343434";
		String product11 = "McCabe Potatoes 2 pounds#0003445655465656#98898348221334#2312343434";
		String product12 = "Monticello spaghetti#1000344565523656#98898348234#2312343434";
		String product13 = "HP Pavilion 14P DV5322#0003445123655656#9889812348234#234343314";
		String product14 = "Motorola RazrD3#0003445165565686#9868898348234#2346863434";
		String product15 = "Play Station 4 with 2 controls#00031445655789656#98898348234#234345434";
		
		productsSeen.add(product1);
		productsSeen.add(product2);
		productsSeen.add(product3);
		productsSeen.add(product4);
		productsSeen.add(product5);
		productsSeen.add(product6);
		productsSeen.add(product7);
		productsSeen.add(product8);
		productsSeen.add(product9);
		productsSeen.add(product10);
		productsSeen.add(product11);
		productsSeen.add(product12);
		productsSeen.add(product13);
		productsSeen.add(product14);
		productsSeen.add(product15);
	}
	
}
